<?php
	class Application_Model_DbTable_GroupUser extends Zend_Db_Table_Abstract{
		protected $_name = "tbl_group_user";
		protected $_primary = 'group_user_id';
		
		
		
		const GROUP_USER_SUPPERADMIN = 1;
		const GROUP_USER_ADMIN = 2;
		
		
		//trả về mảng với key=id và value=name
		public function getPairColumn(){
			$select = $this->select()->order('group_user_name asc');
			$result = $this->fetchAll($select)->toArray();
			$arr = array();
			foreach($result as $item){
				$arr[$item['group_user_id']]=$item['group_user_name'];
			}
			return $arr;
		}
		
		public function getList($filters = array(),$sortType = "ASC",$sortBy = null){
			$select = $this->select()
			->from($this->_name);
			if( count($filters) > 0 ){
				foreach($filters as $key => $value){
					if($key=="keyword" && trim($value)!=""){
						$select->where("group_user_name like ?","%$value%");
							
					}					
				}
			}
				
			if($sortBy==null){
				$sortBy = "group_user_creation_time";
				$sortType = "Desc";
			}
			$select->order($sortBy . " " . $sortType);
		
			return $result = $this->fetchAll($select)->toArray();
		}
	}
?>